public class Array {
    public static void main(String[] args) {
        int[] Array = {1,2,2,3,4,4,4,4,4};
        int i = 0;
        int k = 0;
        int A = 0;
        int tem = Array.length;
        boolean flag = false;
        for( i = 0;i <= tem - 2;i++){
            A = 0;
            for (k = i;k <=tem - 1;k++){
                if (Array[i] == Array[k]){
                    A++;
                    if (A > tem/2){
                        flag = true;
                        break;
                    }
                }
                if (flag == true){
                    break;
                }
            }
            if (flag == true){
                break;
            }
        }
        System.out.println("数组中出现次数大于n/2的值为"+Array[i]);
    }
}
